package com.aba.hos.admin;

import com.aba.hos.dao.AdminDao;
import com.aba.hos.dao.impl.AdminDaoImpl;

import java.sql.SQLException;

public class AdminMain {
    private AdminDao adminDao = new AdminDaoImpl();

    public Admin getAdminRole(String name,String password) throws SQLException {
        // 创建管理员管理器
        AdminManager adminManager = new AdminManager(adminDao.queryAdmin());


        // 显示所有管理员
        for (Admin admin : adminManager.getAllAdmins()) {
            System.out.println(admin);
        }

        // 查找管理员
        Admin foundAdmin = adminManager.findAdminByName(name);
        if (foundAdmin != null) {
            System.out.println(foundAdmin);
        }

        // 管理员登录验证
        Admin authenticatedAdmin = adminManager.authenticate(name, password);
        if (authenticatedAdmin != null) {
            System.out.println("登录成功：" + authenticatedAdmin.getName());
        } else {
            System.out.println("登录失败：用户名或密码错误");
        }
		return authenticatedAdmin;
       
    }
    
    public static void main(String[] args) throws SQLException {
    	AdminMain a =new AdminMain();

    	Admin admin =a.getAdminRole("admin000","123456");

    }
}    